﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using O.M.Production.Application.IService;
using O.M.Production.ErrorCodeEnum;
using O.M.Production.Infrastuecure.IRepository;

namespace O.M.Production.Read.API.Controllers
{
    /// <summary>
    /// Api控制器-工序流程关系表
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Read_Working_ProcedureController : ControllerBase
    {
        private readonly I_working_procedure_Service _working_procedure_service;

        public Read_Working_ProcedureController(I_working_procedure_Service working_procedure_service)
        {
            _working_procedure_service = working_procedure_service;
        }

        /// <summary>
        /// 分页显示-工序流程
        /// </summary>
        /// <param name="WPId_Name">工艺流程编号或名称</param>
        /// <param name="pageSize">页容量</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>统一返回格式</returns>
        [HttpGet]
        public async Task<IActionResult> Get_working_procedure(string? WPId_Name, int pageSize, int pageIndex)
        {
            try
            {
                var list=await _working_procedure_service.Get_working_procedure(WPId_Name, pageSize, pageIndex);
                return Ok(list);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
    }
}
